export const _loadingCount = ref(0)

export const loading = computed({
  get() {
    console.log('执行请求数', _loadingCount.value)
    return _loadingCount.value > 0
  },
  set(val) {
    _loadingCount.value += val ? 1 : -1
    // 处理边界值
    _loadingCount.value = Math.max(0, _loadingCount.value)
    console.log('剩余请求数', _loadingCount.value)
    if (!_loadingCount.value) {
      setTimeout(() => uni.hideLoading())
    }
  },
})
